package com.car.postoffice;

public class CAddress {
	private String scheme;
	private String path;
	
	public CAddress(String scheme, String path){
		this.scheme = scheme;
		this.path = path;
	}

	public String getScheme() {
		return scheme;
	}

	public void setScheme(String scheme) {
		this.scheme = scheme;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}
	
	@Override
	public boolean equals(Object obj){
		if(obj == null ||
		   this.getClass() != obj.getClass()){
			return false;
		}
		if(this == obj){
			return true;
		}
		CAddress addr = (CAddress) obj;
		return  addr.scheme.equals(this.scheme) &&
				addr.path.equals(this.path);
	}
	
	@Override
	public int hashCode(){
		return this.toString().hashCode();
	}
	
	@Override
	public String toString(){
		StringBuffer buffer = new StringBuffer(128);
		buffer.append(this.scheme);
		buffer.append("://");
		buffer.append(this.path);
		return buffer.toString();
	}
}
